package com.dg11185.nearshop.net.entity;

import org.json.JSONObject;

import android.os.Parcel;
import android.os.Parcelable;

public class Photo implements Parcelable {

    public String photoId = "";

    public String name = "";

    public String title = "";

    public String createTime = "";

    public String maxPhotoUrl = "";

    public String midPhotoUrl = "";

    public String minPhotoUrl = "";

    public void parseEntity(JSONObject object) {

        photoId = object.optString("photoId");
        name = object.optString("name");
        title = object.optString("title");
        createTime = object.optString("createTime");
        maxPhotoUrl = object.optString("maxPhotoUrl");
        midPhotoUrl = object.optString("midPhotoUrl");
        minPhotoUrl = object.optString("minPhotoUrl");
    }

    public Photo() {

    }

    public Photo(Parcel in) {
        String[] data = new String[7];
        in.readStringArray(data);
        this.photoId = data[0];
        this.name = data[1];
        this.title = data[2];
        this.createTime = data[3];
        this.maxPhotoUrl = data[4];
        this.midPhotoUrl = data[5];
        this.minPhotoUrl = data[6];
    }

    public static final Parcelable.Creator<Photo> CREATOR = new Creator<Photo>() {

        @Override
        public Photo createFromParcel(Parcel source) {
            return new Photo(source);
        }

        @Override
        public Photo[] newArray(int size) {
            return new Photo[size];
        }
    };

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeStringArray(new String[] { this.photoId, this.name, this.title, this.createTime, this.maxPhotoUrl,
                this.midPhotoUrl, this.minPhotoUrl });
    }
}
